<?php
namespace Wechat\Controller;

//通用Controller类
class CommonController extends \Think\Controller{
   
    public $info;//渲染的数据
    protected $customer;
    protected $customer_id;
    
    public function _initialize(){
        header("Content-Type: text/html; charset=utf-8");

        //判断是否登录
        $customer = session(C('ADMIN_SESSION'));
        if ((ACTION_NAME != 'login') && empty($customer)) {//frameset的掉线处理
            echo '<script>
                    if (window.top == window.self) {
                        window.location.href = "'.U('Admin/Customer/login').'";
                    } else {
                        parent.window.location.reload();
                    }
                </script>';
            exit;
        }

        $this->customer_id = $customer['id'];
        $this->customer    = $customer;

        $this->info = array();
        $this->info['customer_id'] = $customer['id'];
        $this->info['customer']    = $this->customer;
    }
    
}
